/**
 * Created by jn-dinggao on 2017/7/19.
 */

app.factory('InfoRoleService',  function($http, $q, $resource, $cookieStore, serviceUtil, ACTIONS, METHODS ,URL){
    var factory = {};
    var param = {};
    var roleUrl = URL.BASEURL + URL.ROLEURL;

    var initParam = function(){
        param = {};
    };


    factory.getRoleList = function(page,queryParam) {
        initParam();
        param = {};
        param.pageNo = page.pageNo;
        param.pageSize = page.pageSize;
        if(queryParam){
            param.name = queryParam.name;
            param.code = queryParam.code;
        }
        return serviceUtil.excute(roleUrl +'getList', param, METHODS.getList);
    };

    factory.get = function (id) {
        initParam();
        return serviceUtil.excute(URL.BASEURL + URL.ROLEURL + 'get/' + id,param,METHODS.get);
    };

    factory.delete = function(id) {
        initParam();
        param = {};
        return serviceUtil.excute(roleUrl +'delete/' + id, param ,METHODS.delete);
    };

    factory.addRole = function(role) {
        initParam();
        param = {};
        param.id = role.id;
        param.roleName = role.roleName;
        param.codeName = role.codeName;
        param.remark = role.remark;
        return serviceUtil.excute(roleUrl +'add', param ,METHODS.save);
    };

    return factory;
});
